<template>
  <view class="setting-container">
    <!-- 页面标题 -->
    <u-navbar title="偏好设置" :autoBack="true"></u-navbar>

    <!-- 主题设置 -->
    <u-cell-group :border="false">
      <u-cell title="主题设置" :arrow="true" @click="navigateToTheme">
        <text slot="value" class="cell-text">{{ theme }}</text>
      </u-cell>
    </u-cell-group>

    <!-- 通知设置 -->
    <u-cell-group :border="false" style="">
      <u-cell title="接收通知" :arrow="false">
        <u-switch slot="value" v-model="enableNotification" @change="onNotificationChange"></u-switch>
      </u-cell>
    </u-cell-group>

    <!-- 自动播放视频 -->
    <u-cell-group :border="false" style="">
      <u-cell title="自动播放视频" :arrow="false">
        <u-switch slot="value" v-model="autoPlayVideo" @change="onAutoPlayChange"></u-switch>
      </u-cell>
    </u-cell-group>

    <!-- 默认下载路径 -->
    <u-cell-group :border="false" style="">
      <u-cell title="默认下载路径" :arrow="true" @click="chooseDownloadPath">
        <text slot="value" class="cell-text">{{ downloadPath }}</text>
      </u-cell>
    </u-cell-group>

    <!-- 语言设置 -->
    <u-cell-group :border="false" style="">
      <u-cell title="语言设置" :arrow="true" @click="navigateToLanguage">
        <text slot="value" class="cell-text">{{ language }}</text>
      </u-cell>
    </u-cell-group>

    <!-- 数据清理 -->
    <u-cell-group :border="false" style="">
      <u-cell title="清理缓存" :arrow="true" @click="clearCache">
        <text slot="value" class="cell-text">{{ cacheSize }}</text>
      </u-cell>
    </u-cell-group>

    <!-- 版本信息 -->
    <u-cell-group :border="false">
      <u-cell title="当前版本" :arrow="false">
        <text slot="value" class="cell-text">v{{ appVersion }}</text>
      </u-cell>
    </u-cell-group>

  </view>
</template>

<script>
  export default {
    data() {
      return {
        theme: '浅色', // 主题：浅色 / 深色
        enableNotification: true,
        autoPlayVideo: false,
        downloadPath: '/storage/emulated/0/Download/',
        language: '中文',
        cacheSize: '12.4MB',
        appVersion: '1.0.0'
      };
    },
    methods: {
      navigateToTheme() {
        uni.showToast({ title: '跳转到主题设置页', icon: 'none' });
        // 示例：跳转页面
        // uni.navigateTo({ url: '/pages/setting/theme' });
      },
      onNotificationChange(checked) {
        console.log('通知设置更新为:', checked ? '开启' : '关闭');
        uni.showToast({ title: checked ? '已开启通知' : '已关闭通知' });
      },
      onAutoPlayChange(checked) {
        console.log('自动播放视频更新为:', checked ? '开启' : '关闭');
        uni.showToast({ title: checked ? '视频将自动播放' : '视频需手动播放' });
      },
      chooseDownloadPath() {
        uni.showToast({ title: '选择下载路径', icon: 'none' });
        // 可调
      },
      clearCache() {
        console.log(666)
      }

    }
  }
</script>

<style>

</style>